{extend name='public/base'} {block name='content'}

<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        {$item['item1']}
        <small>{$item['item2']}</small>
    </h1>
    <ol class="breadcrumb">
        <li>
            <a href="#">
                <i class="fa fa-dashboard"></i> {$item['item1']}</a>
        </li>
        <li class="active">{$item['item2']}</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">
    <div class="panel panel-default">
        <ul class="layui-nav layui-bg-green">
            <li class="layui-nav-item layui-this"><a href="{:url('merchant/diagnosis/index')}">排队接诊</a></li>
            <li class="layui-nav-item "><a href="{:url('merchant/diagnosis/record')}">接诊记录</a></li>
        </ul>
    </div>

    <!-- Main content -->
    <section class="content">
            <!-- Info boxes -->
            <div class="row">
              <!-- <div class="clearfix visible-sm-block"></div> -->
      
              {volist name='list' id='vo'}

                <div class="col-md-3 col-sm-6 col-xs-12">
                    <div class="info-box">
                        <span class="info-box-icon bg-green"><img src="/static/img/user.png" alt="" class='fa' style="width:50px"></span>
            
                        <div class="info-box-content">
                            <span class="info-box-number">{$vo.patientInfo.name}</span>
                            <span class="info-box-text">
                                卡号:{empty name="$vo.patientInfo.card_id"}
                                    {$vo.patientInfo.phone_id}
                                {else /}
                                    {$vo.patientInfo.card_id}
                                {/empty}
                            </span>
                            <span class="info-box-text">
                                {switch name="$vo.patientInfo.sex"}
                                    {case value="1"}男{/case}
                                    {case value="2"}女{/case}
                                    {default /}不详
                                {/switch}
                            </span>
                            <span class="info-box-text">排队时间:{$vo.addtime}</span>
                        </div>
                    <!-- /.info-box-content -->
                    </div>
                    <a href="{:url('merchant/diagnosis/treat', ['id' => $vo['patient_id']])}">
                        <div class="info-box-btn">接诊</div>
                    </a>
                    <!-- /.info-box -->
                </div>

              {/volist}


            </div>
            <!-- /.row -->
            <div class="page page_right">
                    <div>
                      {$list->render()}
                    </div>
            </div>

    </section>
    <!-- /.row -->
    <strong id="count"></strong>
    <h1 id="target"></h1>
</section>
<!-- /.content -->


{/block} {block name='script'}
<script src="http://cdn.bootcss.com/jquery/3.1.0/jquery.min.js"></script>
<script src='http://cdn.bootcss.com/socket.io/1.3.7/socket.io.js'></script>
<script>
    jQuery(function ($) {

        // 连接服务端
        var socket = io('http://127.0.0.1:2120'); //这里当然填写真实的地址了
        // uid可以是自己网站的用户id，以便针对uid推送以及统计在线人数
        uid = 123;
        // socket连接后以uid登录
        socket.on('connect', function () {
            socket.emit('login', uid);
        });
        // 后端推送来消息时
        socket.on('new_msg', function (msg) {
            console.log("收到消息：" + msg);
            $('#target').append(msg).append('<br>');
            layer.msg('您有新的信息，请注意查收', {
                time: 20000, //20s后自动关闭
                btn: ['确定']
            });
        });
        // 后端推送来在线数据时
        socket.on('update_online_count', function (online_stat) {
            console.log(online_stat);
            $('#count').html(online_stat);
        });
    })

</script>


<script>
    //增加数据
    $(function () {
        //表格功能
        $('#example1').DataTable({
            'paging': true,
            'lengthChange': true,
            'searching': true,
            'ordering': false,
            'info': true,
            'autoWidth': true
        });


        //JQuery里面的方法,ajaxSubmit来提交表单
        var options = {
            type: 'post', //post提交
            //url:'http://ask.tongzhuo100.com/server/****.php?='+Math.random(),   //url
            dataType: "json", //json格式
            data: {}, //如果需要提交附加参数，视情况添加
            clearForm: false, //成功提交后，清除所有表单元素的值
            resetForm: false, //成功提交后，重置所有表单元素的值
            cache: false,
            async: false, //同步返回
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg, {
                        icon: 2,
                        offset: 'm',
                        time: 1000
                    });
                } else {
                    layer.msg(data.msg, {
                        icon: 1,
                        offset: 'm',
                        time: 1500
                    }, function () {
                        location.reload();
                    });
                }
                //服务器端返回处理逻辑
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败:服务器处理失败');
            }
        };

        layui.use('form', function(){
            var form = layui.form;
            $('#mainForm').ajaxForm(options).submit(function(data){});
        });

    })
    //新增用户的模态框数据清除
    $("#addModal,#editModal").on('hide.bs.modal', function () {
        $('#addReset').click();
    });
    //加载缓冲动画
    $("#addModal,#editModal").on('show.bs.modal', function () {
        layer.closeAll();
    });


    //删除用户
    function delete_register(id) {
        layer.confirm('确定删除吗？', function (index) {
            $.ajax({
                    url: '{:url("merchant/Register/delete_register")}',
                    type: 'get',
                    dataType: 'json',
                    data: {
                        id: id
                    },
                })
                .done(function (data) {
                    //回调提示
                    if (data.code == 0) {
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 1000
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 1,
                            time: 1500
                        }, function () {
                            location.reload();
                        });
                    }
                })
        })
    }
</script>
{/block}